<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" v-model="myValue" placeholder="请输入1-100之间的整数">
    <input type="button" value="按钮" @click="fn()">
    <h3 v-text="info"></h3>
</div>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let x = parseInt(Math.random()*100)+1;//得到1-100随机整数
    let vm = new Vue({
        el:"div",
        data:{myValue:"",info:""},
        methods:{
            fn:function () {
                if (vm.myValue>x){
                    vm.info="猜大了";
                }else if (vm.myValue<x){
                    vm.info="猜小了";
                }else{
                    vm.info="恭喜你 猜对了!";
                }
            }
        }
    })
</script>
</body>
</html>